{% set pypi_name = 'oslo.db' %}
{% set upstream_version = upstream_version('8.4.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack oslo.db library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PyMySQL') }}
BuildRequires:  {{ py3('alembic') }}
BuildRequires:  {{ py3('debtcollector') }}
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.context') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('psycopg2') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('reno') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('sqlalchemy-migrate') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testresources') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
The OpenStack Oslo database handling library. Provides database connectivity
to the different backends and helper utils.
* Documentation: https://docs.openstack.org/oslo.db/latest/
* Source: https://opendev.org/openstack/oslo.db/
* Bugs: https://bugs.launchpad.net/oslo.db

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack oslo.db library
Requires:       {{ py3('PyMySQL') }}
Requires:       {{ py3('SQLAlchemy') }}
Requires:       {{ py3('alembic') }}
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.context') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('psycopg2') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('sqlalchemy-migrate') }}
Requires:       {{ py3('stevedore') }}
Requires:       {{ py3('testresources') }}
Requires:       {{ py3('testscenarios') }}

%description -n {{ py2name(py_versions='py3') }}
The OpenStack Oslo database handling library. Provides database connectivity
to the different backends and helper utils.
* Documentation: https://docs.openstack.org/oslo.db/latest/
* Source: https://opendev.org/openstack/oslo.db/
* Bugs: https://bugs.launchpad.net/oslo.db

This package contains the Python 3.x module.

%package -n {{ py2name() }}-doc
Summary:        Documentation for the Oslo database handling library
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n {{ py2name() }}-doc
Documentation for the Oslo database handling library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst ChangeLog
%{python3_sitelib}/oslo_db
%{python3_sitelib}/*.egg-info

%files -n {{ py2name() }}-doc
%license LICENSE
%doc doc/build/html

%changelog
